package com.taobao.dao.impl;

import java.sql.ResultSet;

import com.taobao.dao.CommonDBDao;
import com.taobao.dao.ReceiveLastOneDBDao;
import com.taobao.pojo.ConfirmTime;
import com.taobao.pojo.DBContext;
import com.taobao.pojo.Task;

public class ReceiveLastOneDBDaoImpl extends CommonDBDao implements ReceiveLastOneDBDao {

	@Override
	public Task getLastTask() throws Exception {
		String sql = "select * from receive order by ptime desc limit 0,1";
		return (Task) selectRequest(sql, true);
	}

	@Override
	public Object process(DBContext context) throws Exception {
		Task task = null;
		ResultSet rs = context.getResultSet();
		if (rs.next()) {
			task = new Task();
			task.setId(Long.parseLong(rs.getString(2)));
			task.setName(rs.getString(3));
			task.setTbName(rs.getString(4));
			task.setPublishPoint(rs.getDouble(5));
			task.setPrice(rs.getDouble(6));
			// task.setPublishTime(publishTime)(rs.getDate(7));
			task.setSmallUser(rs.getString(8));
			task.setConfirmTime(new ConfirmTime(-1, rs.getString(9)));
			task.setHpWord(rs.getString(10));
			task.setTbUrl(rs.getString(11));
		}
		return task;
	}

}
